import {
  CreateRoleReq,
  GetRolePageListReq,
  GetRolePageListRes,
  UpdateRoleReq,
} from './model/roleModel';
import { GetOptionsModel } from '../model/baseModel';
import { defHttp } from '@/utils/http/axios';

enum Api {
  Role = '/system/role',
  RoleOptions = '/system/role/options',
  RoleWithId = '/system/role/{role_id}',
}

//role
export const apiGetRoleListByPage = (params?: GetRolePageListReq) =>
  defHttp.get<GetRolePageListRes>({ url: Api.Role, params });

export const apiCreateRole = (params: CreateRoleReq) =>
  defHttp.post({ url: Api.Role, params: params });

export const apiUpdateRole = (params: UpdateRoleReq) =>
  defHttp.put({ url: Api.Role, params: params });

export const apiDeleteRole = (roleId: number) =>
  defHttp.delete({ url: Api.RoleWithId.replace('{role_id}', roleId.toString()) });

export const apiGetRoleOptions = (params?: GetRolePageListReq) =>
  defHttp.get<GetOptionsModel>({ url: Api.RoleOptions, params });
